package com.clz.appdesign.myapp.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * @author chenliangzhi
 * @date 2018/5/22
 * @describe
 */

public class MyTextView extends View {
    public MyTextView(Context context) {
        super(context);
    }

    public MyTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MyTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int baseLineX = 0;
        int baseLineY = 200;
        //画基线
        Paint paint =new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(Color.RED);
        paint.setTextSize(80);
        paint.setStrokeWidth(5);
        canvas.drawLine(baseLineX,baseLineY,3000,baseLineY,paint);
        String text="再见只是陌生人";
        paint.setColor(Color.GREEN);
        canvas.drawText(text,baseLineX,baseLineY,paint);
    }
}
